package shared;

import java.io.IOException;
import java.io.StringReader;

import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;


public abstract class SimpleXMLParser implements ContentHandler {

//	private ContentHandler mHandler = null;
//	
//	public SimpleXMLParser(ContentHandler iHandler) {
//		mHandler = iHandler;
//	}
	
	public void parseString(String iString) throws SAXException, IOException {
		XMLReader xmlreader = XMLReaderFactory.createXMLReader();
		xmlreader.setContentHandler(this);
		xmlreader.parse(new InputSource(new StringReader(iString)));
	}
	
	@Override
	public void characters(char[] ch, int start, int length)
			throws SAXException {
	}

	@Override
	public void endDocument() throws SAXException {
	}

	@Override
	public void endElement(String uri, String localName, String name)
			throws SAXException {
	}

	@Override
	public void endPrefixMapping(String prefix) throws SAXException {
	}

	@Override
	public void ignorableWhitespace(char[] ch, int start, int length)
			throws SAXException {
	}

	@Override
	public void processingInstruction(String target, String data)
			throws SAXException {
	}

	@Override
	public void setDocumentLocator(Locator locator) {
	}

	@Override
	public void skippedEntity(String name) throws SAXException {
	}

	@Override
	public void startDocument() throws SAXException {
	}

//	@Override
//	public void startElement(String uri, String localName, String name,
//			Attributes atts) throws SAXException {
//		mHandler.startElement(uri, localName, name, atts);
//	}

	@Override
	public void startPrefixMapping(String prefix, String uri)
			throws SAXException {
	}

}
